package com.glsc.ngateway.common.base.repo.mysql.flowable;

import com.glsc.ngateway.common.base.domain.mysql.flowable.FlowableEhrEmp;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author lium
 * @date 2021/12/21
 */
public interface FlowableEhrEmpRepo extends JpaRepository<FlowableEhrEmp, Long>, JpaSpecificationExecutor<FlowableEhrEmp> {

    FlowableEhrEmp findByBadge(String userId);

    List<FlowableEhrEmp> findByTitle(String title);

    List<FlowableEhrEmp> findByName(String name);

    List<FlowableEhrEmp> findAllByBadgeIn(List<String> badge);

    @Transactional
    @Modifying
    @Query(value = "truncate table t_flowable_ehr_emp", nativeQuery = true)
    Integer truncateTableEhrEmp();

    @Query(value = "select m.badge from t_flowable_ehr_emp m ", nativeQuery = true)
    List<String> findExistIdList();

}
